package com.bms.common.base.web;

import com.bms.common.base.common.bean.Result;
import com.bms.common.base.common.exception.EnumSvrResult;


public abstract class BaseController {
	
	/**
	 * 成功,返回状态
	 * @return
	 */
	public Result success() {
		return new Result();
	}
	
	/**
	 * 失败,返回状态及原因
	 * @param message 消息
	 * @return
	 */
	public Result fail(EnumSvrResult result) {
		Result bean = new Result();
		bean.setMessage(result.getName());
		bean.setStatus(result.getVal());
		return bean;
	}
	
	public Result fail(String message,String status) {
		Result bean = new Result();
		bean.setMessage(message);
		bean.setStatus(status);
		return bean;
	}
	
	public Result error() {
		Result bean = new Result();
		bean.setMessage(EnumSvrResult.ERROR.getName());
		bean.setStatus(EnumSvrResult.ERROR.getVal());
		return bean;
	}
	
	
	/**
	 * 成功，返回json数据
	 * @param message 消息
	 * @return
	 */
	public Result json(Object data) {
		Result bean = new Result();
		bean.setData(data);
		return bean;
	}
	
}